
package fr.greta.centreFormation.controller;

import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import fr.greta.centreFormation.bean.Candidat;
import fr.greta.centreFormation.bean.Etat;
import fr.greta.centreFormation.dao.CandidatHome;
import fr.greta.centreFormation.dao.EtatHome;

/**
 * Servlet implementation class GetCandidat
 */
public class GetCandidat extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public GetCandidat() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		//HttpSession session= request.getSession(true);

		int idPersonne =Integer.parseInt(request.getParameter("idPersonne"));

		Candidat leCandidat=CandidatHome.selectUnCandidatByIdPersonne(idPersonne);
		ArrayList<Etat> lesEtats= EtatHome.selectAllEtats();
		
		request.setAttribute("leCandidat", leCandidat);
		request.setAttribute("lesEtats", lesEtats);

		request.getRequestDispatcher("modifFicheCandidat.jsp").forward(request, response);
	}
}

